//
// Created by 11510 on 2024/7/19.
//

#ifndef DAY80_DEMO3_CUSTOMBUTTON_H
#define DAY80_DEMO3_CUSTOMBUTTON_H
#include <QEvent>
#include <QMouseEvent>
#include <QPushButton>
#include <QDebug>
class CustomButton : public QPushButton {

public:
    CustomButton(const QString &text, QWidget *parent = nullptr) :
            QPushButton(text, parent) {
        this->setObjectName(text);
    }

protected:
    bool event(QEvent *e) override {
        if (e->type() == QEvent::MouseButtonRelease) {
            qDebug() << objectName();
            return false;   /* false说明本对象没有处理完事件，交给父类 */
        }
        /* 调父类才会调用handle */
        return QPushButton::event(e);
    }

};


#endif //DAY80_DEMO3_CUSTOMBUTTON_H
